<template>
    <el-dialog v-model="visible" title='手动考核' :close-on-click-modal="false" :close-on-press-escape="false">
        <el-form :model="dataForm" ref="dataFormRef" @keyup.enter="dataFormSubmitHandle()" label-width="120px">
            <el-row>
                <el-col :span="24">
                    <el-form-item label="姓名">
                        <el-input v-model="dataForm.username" placeholder="请输入"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- 时间 -->
            <el-row>
                <el-col :span="24">
                    <el-form-item label="时间">
                        <el-input v-model="dataForm.createdTime" placeholder="请输入"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- 考核 -->
            <el-row>
                <el-col :span="24">
                    <el-form-item label="考核">
                        <el-radio-group v-model="dataForm.result">
                            <el-radio label="0">达标</el-radio>
                            <el-radio label="1">不达标</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- 备注 -->
            <el-row>
                <el-col :span="24">
                    <el-form-item label="备注">
                        <el-input v-model="dataForm.remark" placeholder="请输入" style="height: 50px"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- 保存 取消 -->
            <el-form-item style="margin-top: 50px;">
                <el-button type="primary" @click="dataFormSubmitHandle()">确定</el-button>
                <el-button @click="visible = false">取消</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>

<script lang="ts" setup>
import { nextTick, reactive, ref, watch } from "vue";
import baseService from "@/service/baseService";
import { useI18n } from "vue-i18n";
import { ElMessage } from "element-plus";
const { t } = useI18n();
const emit = defineEmits(["refreshDataList"]);
const visible = ref(false);
const dataFormRef = ref();

const dataForm = reactive({
    id: "",
    username: "",//姓名
    remark: "",//备注
    createdTime: "",//时间
    result:"",
    userId:"",
});


//初始化
const init = (id: number,) => {
    visible.value = true;
    dataForm.id = "";
    // 重置表单数据
    if (dataFormRef.value) {
        dataFormRef.value.resetFields();
    }
    //     if (id) {
    //     getEdit(id)
    //   }
};


// // //编辑
// const getEdit = (id: number) => {
//   baseService.get("/tccc/reportDescribeTelCdr" + id).then((res) => {
//     Object.assign(dataForm, res.data);
//   });
// };



// 表单提交
const dataFormSubmitHandle = () => {
    dataFormRef.value.validate((valid: boolean) => {
        if (!valid) {
            return false;
        }
        ( baseService.post)(
            "/crm/nocdescribetelassess/saveorupdate",dataForm).then((res) => {
                ElMessage.success({
                    message: t("prompt.success"),
                    duration: 500,
                    onClose: () => {
                        visible.value = false;
                        emit("refreshDataList");
                    }
                });
            });
    });
};

defineExpose({
    init
});
</script>

<style lang="scss" scoped>
.el-checkbox {
    width: 82px;
}

::v-deep .el-form-item__error {
    width: 50px !important;
}
</style>